<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>注册页</title>

	<script src="js/jquery-3.6.0.min.js"></script>
	<script src="js/axios-0.18.0.js"></script>

</head>
<body>
	<form action="register.do" id="form1">
		账号:<input type="text" name="username" id="username">
		密码:<input type="text" name="password" id="password">
		邮箱:<input type="text" name="email" id="email">
		手机:<input type="text" name="phone" id="phone">
		<input type="button" value="注册" onclick="func()">
	</form>
</body>

<script>
	function func() {
		let usernameRegex = /^[a-z]\d{6,20}$/;
		let usernameValue = $("#username").val();

		if(!usernameRegex.test(usernameValue)){
			alert("账号格式不对");
			return;
		}

		let passwordRegex = /^\d{6,20}$/;
		let passwordValue = $("#password").val();

		if(!passwordRegex.test(passwordValue)){
			alert("密码格式不对");
			return;
		}

		let emailRegex = /^\w+@\w+\.\w+$/;
		let emailValue = $("#email").val();

		if(!emailRegex.test(emailValue)){
			alert("邮箱格式不对");
			return;
		}

		let phoneRegex = /^1[3578]\d{9}$/;
		let phoneValue = $("#phone").val();

		if(!phoneRegex.test(phoneValue)){
			alert("手机格式不对");
			return;
		}

		$("#form1").submit();
	}
</script>


</html>